<script type="text/javascript">
		function validate(){
			var help = true; 
			//var match = $("#email").val().match(/[a-zA-Z_.0-9]{1,255}@.*[.]*/g);
			if($("#firstname").val()==""){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("First name can not be empty");
				$("#firstname").focus();
				return help=false;
			}
			if( $("#lastname").val()=="" ){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("Last name can not be empty");
				$("#lastname").focus();
				return help=false;
			}
			if( $("#username").val()=="" ){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("Username can not be empty");
				$("#username").focus();
				return help=false;
			}
			/*if( $("#email").val()=="" ){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("Email can not be empty");
				$("#email").focus();
				return help=false;
			}*/ 
			//[a-zA-Z_.0-9]{1,255}@.*[.].*
			/*
			if(match==null){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("Email format is not correct");
				$("#email").focus();
				return help=false;
			} */
				
			if($("#password").val()==""||$("#confirmpwd").val()==""||($("#password").val()!=$("#confirmpwd").val())){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("Password and confirm password can not be empty and have to be matched");
				$("#password").val("");
				$("#confirmpwd").val("");
				$("#password").focus();
				return help=false;
			}
			if($("#password").val().length<6){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("Password and confirm password can not less than 6 characters");
				$("#password").val("");
				$("#confirmpwd").val("");
				$("#password").focus();
				return help=false;
			}
			if($("#captcha").val().length<6){
				$(".msg_h").css("color","#AF282A");
				$(".msg_h").html("Verification code cannot empty");
				$("#captcha").focus();
				return help=false;
			}
			
			return help;
		}
		$(document).ready(function(){ 
			$("#email").keyup(function(){
				//[a-zA-Z_.0-9]{1,255}@.*[.].*
				var match = $(this).val().match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/);
				var mail=$("#email").val();
				if(match!=null){
					$(".msg_h").css("color","green");
					$(".msg_h").html("Email format is correct");
					$("#btn_can").attr("disabled",false);
				}else if(mail==""){
					$("#btn_can").attr("disabled",false);
					$(".msg_h").html('');
				}
				else{
						$(".msg_h").css("color","#AF282A");
						$(".msg_h").html("Email format is not correct");
						$("#email").focus();
						$("#btn_can").attr("disabled",true);
						return help=false;
				}
				return help;
			}); 
			$("#username").bind("blur",function(){
				var usr=$("#username").val();
					$.ajax({
						type:"POST",
						url:"/index.php/candidate/checkUserNameCan",
						data:{username:$("#username").val()},
						success:function(response){
							//alert(response);
							 if(response == "ok" && $("#username").val()!="" ){
								  $(".msgchks").html("Username already exist,Please check it again!").show(); 
								   $(".msgchkw").hide(); 
								   $("#btn_can").attr("disabled",true);
							 }else if(response == "no" && $("#username").val()!="" ){  
								 $(".msgchks").hide();
								 $("#btn_can").attr("disabled",false);
							}else if(usr==""){
								 $(".msgchks").hide();
								 $("#btn_can").attr("disabled",false);
							}
						 }
					});
				});
		});
	</script>
</head>
<body>
	<div class="main_rgt">
		<div class="content">
			<form id="form" action="/index.php/candidate/save" method="POST" class="login" onsubmit="return validate();">
			  <div class="heads">Sign Up as a new Employer</div>
			 <!--Employer-->
				<table class="table_form can" border="0" cellpadding="3" cellspacing="1" id="customize1">
						<tbody><tr>
						  <td height="31" class="form_field"><label for="firstname">First Name : </label><span>*</span> </td>
						  <td class="form_value">
						  	<input size="35" name="firstname" id="firstname" type="text" value="">
						  </td>
						</tr>
						<tr>
						  <td height="28" class="form_field"><label for="lastname">Last Name : </label><span>*</span> </td>
						  <td class="form_value">
						  	<input size="35" name="lastname" id="lastname" type="text" value="">
						  </td>
						</tr>
						 <tr>
						  <td height="28" class="form_field"><label for="username">Nickname : </label></td>
						  <td class="form_value">
						  	<input size="35" name="nickname" id="nickname" type="text" value="">
						  </td>
						</tr>
						<tr>
						  <td height="28" class="form_field"><label for="username">Username : </label><span>*</span> </td>
						  <td class="form_value">
						  	<input size="35" name="username" id="username" type="text" value="">
						  	<div class="msgchks" style="color:red;font-size: 12px; font-family: 'Trebuchet MS'"></div>
					      	<div class="msgchkw" style="color:#5E9C00;font-size: 12px; font-family: 'Trebuchet MS'"></div>
						  </td>
						</tr>
						<tr>
						  <td height="30" class="form_field"><label for="email"> E-mail : </label><span></span></td>
						  <td class="form_value">
						  	<input size="35" name="email" id="email" type="text" value="">
						  </td>
						</tr>
						<tr>
						  <td height="30" class="form_field"><label for="password">Password: </label><span>*</span></td>
						  <td class="form_value">
						  	<input size="35" name="password" id="password" type="password" value="">
						  </td>
						</tr>
						<tr>
						  <td height="30" class="form_field"><label for="confirmpwd">Confirm Password : </label><span>*</span></td>
						  <td class="form_value">
						  	<input size="35" type="password" name="confirmpwd" id="confirmpwd">
						  </td>
						</tr>
						 <tr>
					      <td height="30" class="form_field"><label for="confirmpwd">Enter verification Code:</label><span>*</span>
					      <div&#8203; class="all_font">សូមវាយបញ្ចូលលេខសំងាត់ ទាំង6ខ្ទង់ក្នុងប្រអប់នេះ
					      </div&#8203;></td>
					      <td class="form_value">
					      	<input type="text" name="captcha" id="captcha" style="width:150px;">
					      	<img src="/index.php/captcha/code" alt="Captchar Verification Code" style="position:relative;display:inline-block;top:10px;">
					      	<div class="msgcaptcha" style="color:#ED1846;font-size: 12px; font-family:'Trebuchet MS'"></div>
					      	</td>
					    </tr>
						<tr>
							<td colspan="2" align="center">
								<center>
									<input type="submit" id="btn_can" class="button" name="btn_can" value="Sign Up" title="Sign Up">
									<input type="button" class="button" value="Back" title="Go Home Page" onclick="window.location.href='/index.php/page/home'">
								</center>
							</td>
						</tr>
						<tr>
							<td colspan="2" align="center">
								<div class="msg_h" style="height: 30px; line-height: 30px; margin: 5px 0px; font-size: 14px;  color: #AF282A;"></div>
							</td>
						</tr>
					</tbody></table>
			</form>
		</div>
	</div>